import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/util/utils.dart';

import '../../login/page/user_manager.dart';

class HomeSwiperCell extends StatelessWidget {
  final _imageUrl = [
    "https://apk-1256738511.file.myqcloud.com/FlutterTrip/images/100h10000000q7ght9352.jpg",
    "https://apk-1256738511.file.myqcloud.com/FlutterTrip/images/300h0u000000j05rnD96B_C_500_280.jpg",
    'https://tse2-mm.cn.bing.net/th?id=OIP.ge1MM8IlMmFzyTrDaFjuXwHaFd&w=267&h=196&c=7&o=5&dpr=2&pid=1.7',
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      // color: Colours.bg_color,
      width: ScreenUtil.getScreenW(context),
      height: ScreenUtil.getScreenW(context) * 23 / 75,
      padding: EdgeInsets.fromLTRB(15, 10, 15, 10),
      decoration: BoxDecoration(
        borderRadius: new BorderRadius.circular((5.0)),
        color: Colours.bg_color,
      ),
      child: Swiper(
        itemCount: _imageUrl.length,
        autoplay: true,
        onTap: (index) => print('点击了第$index'),
        itemBuilder: (BuildContext content, int index) {
          return CachedNetworkImage(
            fit: BoxFit.cover,
            imageUrl: _imageUrl[index],
              httpHeaders: {"Cookie":UserManager.cookieStr},
            placeholder: (context, url) => new ProgressView(),
            errorWidget: (context, url, error) => new Icon(Icons.error),
          );
        },
        pagination: SwiperPagination(
            margin: const EdgeInsets.fromLTRB(0, 0, 20, 10),
            alignment: Alignment.bottomRight,
            builder: DotSwiperPaginationBuilder(
              activeColor: Colours.text_gray,
              color: Colours.bg_gray,
            )),
      ),
    );
  }
}
